(function() {
    "use strict";
    var e = window.jQuery,
        t = window.qh360cp,
        n = window._,
        r = {
            getSrcdata: function() {
                var n = this,
                    r = {},
                    i = [],
                    s = [],
                    o = [],
                    u = {},
                    a = {},
                    f = [],
                    l = [],
                    c = [],
                    h = [],
                    p = [],
                    d = [],
                    v = e("#redboxlist li .btn-boll-active"),
                    m = e("#blueboxlist li .btn-boll-active"),
                    g = v.length;
                v.each(function(t, r) {
                    var s = e(r).html() * 1;
                    i.push(s), o.push(e(r).html().substr(-1, 1) * 1), s > n.options.dahao && l.push(s), s % 2 == 1 ? c.push(s) : h.push(s), t > 0 && i[t - 1] == s - 1 ? d.push(s) : (d.length > 1 && (p.push(d), d = []), d[0] = s), t == g - 1 && d.length > 1 && (p.push(d), d = [])
                }), m.each(function(t, n) {
                    s.push(e(n).html() * 1)
                });
                if (e("#redboxlist").hasClass("wshu")) {
                    var y = [],
                        b = e("#redboxlist li .btn-boll");
                    b.each(function(t, n) {
                        t % 10 == 0 && t > 0 && (f.push(y), y = []), e(n).hasClass("btn-boll-active") && y.push(e(n).html() * 1), t == b.length - 1 && f.push(y)
                    })
                }
                o = o.sort(function(e, t) {
                    return e - t
                });
                var w = {
                    cd: [],
                    co: [],
                    hit: {}
                };
                e("#red_sdlist  .boll").each(function() {
                    e(this).hasClass("redboll") ? (w.cd.push(e(this).attr("value")), w.co.push(!0)) : w.co.push(!1)
                });
                var E = 0;
                n.options.mwh && !n.options.zuxuan ? E = n.countZhushu(f) : E = n.countZhushu(i.length, s.length);
                if (E.iserror) {
                    t.lightbox.alert({
                        content: E.eText,
                        on_focus: ".lightbox_confirm"
                    }), n.options.Cbox && e(n.options.Cbox).removeClass("btn-boll-active");
                    return
                }
                return f.length > 0 && (r.wshu = f), r.rlist = i, r.blist = s, r.dahao = l, r.jihao = c, r.ouhao = h, r.lhao = p, r.gewei = o, r.zs = E.count, r.dan = w, this.srcData = r, this.options.wcount = f.length, r
            },
            syncModel: function (t) {
                var n = this;
                if (!t) return;
                e("#redcount").html(t.rlist.length), e("#bluecount").html(t.blist.length), e("#vszs").html(t.zs), e("#vsmoney").html(n.formatBigNum(t.zs * 2)), this.resetNoFilter(0)
            },
            allHao: function(n) {
                var r = this,
                    i = [],
                    s = 0,
                    o = 0,
                    u = e(n).parents(".ht").attr("atdiv"),
                    a = e("#" + u);
                u == "blueboxlist" ? (s = e("#redboxlist .btn-boll-active").length, o = a.find(".btn-boll").length) : u == "redboxlist" && (o = e("#blueboxlist .btn-boll-active").length, s = a.find(".btn-boll").length);
                var f = 0;
                if (r.options.mwh) {
                    var l = [];
                    for (var c = 0; c < r.options.wcount; c++) l.push([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
                    f = r.countZhushu(l)
                } else f = r.countZhushu(s, o); if (f.iserror) {
                    t.lightbox.alert({
                        content: f.eText,
                        on_focus: ".lightbox_confirm"
                    });
                    return
                }
                a.find(".btn-boll").addClass("btn-boll-active"), r.syncModel(r.getSrcdata())
            },
            colorHao: function (e) {
              
                var t = e.split("+"),
                    n = '<span class="red">' + t[0] + "</span>";
                return t[1] && (n += ' + <span class="blue">' + t[1] + "</span>"), n
            },
            getHZ: function(t) {
                var n = 0;
                return e.each(t, function(e, t) {
                    n += t * 1
                }), n
            },
            getKD: function(e) {
                var t = e.length;
                return e[t - 1] - e[0]
            },
            getDXB: function(t) {
                var n = this,
                    r = 0,
                    i = 0;
                return e.each(t, function(e, t) {
                    t > n.options.dahao ? r++ : i++
                }), r + "<strong>:</strong>" + i
            },
            getJOB: function(t) {
                var n = 0,
                    r = 0;
                return e.each(t, function(e, t) {
                    t % 2 == 0 ? r++ : n++
                }), n + "<strong>:</strong>" + r
            }
        };
    e.extend(t.QFilter, r)
})();